<div class="panel panel-default">
	<div class="panel-heading">
		<?php 
		$this->widget('zii.widgets.CBreadcrumbs',array(
				'links'=>array(
						'后台管理',
						'编辑文章'
		)
		));
		?>
	</div>
	<div class="panel-body">
		<?php 
			$form = $this->beginWidget('CActiveForm', array(
					'htmlOptions'=>array('class'=>'form-horizontal')
			));
		?>
			<div class="form-group">
				<?php 
					echo $form->labelEx($articleModel, 'title', array('class'=>'col-sm-2 control-label'));
				?>
				<div class="col-sm-5">
					<?php 
					echo $form->textField($articleModel, 'title', array('class'=>'form-control'));
					?>
				</div>
			</div>
			<div class="form-group">
				<?php 
					echo $form->labelEx($articleModel, 'category_id', array('class'=>'control-label col-sm-2'));
				?>
				<div class="col-sm-4">
					<?php 
						echo $form->dropDownlist($articleModel, 'category_id', $cateTree, array('class'=>'form-control'));
					?>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">文章属性：</label>
				<div class="col-sm-10">
				<?php foreach($attr as $v):?>
					<label class="checkbox-inline">
					  <input type="checkbox" <?php if(in_array($v->attr_id, $existAttr)){echo 'checked="checked"'; } ?> value="<?php echo $v->attr_id;?>" name="attr_id[]"> <?php echo $v->attr_name;?>
					</label>
				<?php endforeach;?>
				</div>
			</div>
			<div class="form-group">
				<?php 
					echo $form->labelEx($articleModel,'pic',array('class'=>'col-sm-2 control-label'));
				?>
				<div class="col-sm-4">
					<?php 
					echo $form->textField($articleModel, 'pic', array('id'=>'pic', 'class'=>'form-control'));
					?>
				</div>
				<div class="col-sm-2">
				<script type="text/plain" id="j_ueditorupload" style="height:5px;display:none;" ></script>
				    <script>
      //实例化编辑器
      var o_ueditorupload = UE.getEditor('j_ueditorupload',
      {
        autoHeightEnabled:false
      });
      o_ueditorupload.ready(function ()
      {
	
	o_ueditorupload.hide();//隐藏编辑器
	
	//监听图片上传
	o_ueditorupload.addListener('beforeInsertImage', function (t,arg)
	{
//           alert('这是图片地址：'+arg[0].src);
          $('#pic').val(arg[0].src);
	});
      });
      
      //弹出图片上传的对话框
      function upImage()
      {
        var myImage = o_ueditorupload.getDialog("insertimage");
        myImage.open();
      }
    </script>
					<a class="btn btn-default" onClick="upImage()" href="javascript:;">上传缩略图</a>
				</div>
			</div>
			<div class="form-group">
				<?php 
				echo $form->labelEx($articleModel, 'keywords', array('class'=>'col-sm-2 control-label'));
				?>
				<div class="col-sm-8">
					<?php 
					echo $form->textField($articleModel, 'keywords', array('class'=>'form-control', 'placeholder'=>'关键字'));
					?>
				</div>
			</div>
			<div class="form-group">
				<?php 
				echo $form->labelEx($articleModel,'description', array('class'=>'col-sm-2 control-label'));
				?>
				<div class="col-sm-8">
					<?php 
					echo $form->textArea($articleModel, 'description', array('rows'=>'2', 'class'=>'form-control', 'placeholder'=>'描述'));
					?>
				</div>
			</div>
			<div class="form-group">
				<?php 
				echo $form->labelEx($articleModel, 'content', array('class'=>'col-sm-2 control-label'));
				?>
				<div class="col-sm-8">
					<!--style给定宽度可以影响编辑器的最终宽度-->
					<?php 
					echo $form->textArea($articleModel, 'content', array('id'=>'editor','style'=>'width:100%;height:300px;'));
					?>
					<?php 
						echo $form->error($articleModel, 'content');
					?>
					<script>
					var ue = UE.getEditor('editor');
					</script>
				</div>
			</div>
			<div class="form-group">
				<?php 
					echo $form->labelEx($articleModel, 'writer', array('class'=>'col-sm-2 control-label'));
				?>
				<div class="col-sm-3">
					<?php 
					echo $form->textField($articleModel, 'writer', array('class'=>'form-control'));
					?>
				</div>
			</div>
			<div class="form-group">
				<?php 
					echo $form->labelEx($articleModel, 'source', array('class'=>'col-sm-2 control-label'));
				?>
				<div class="col-sm-3">
					<?php 
					echo $form->textField($articleModel, 'source', array('class'=>'form-control'));
					?>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-5 col-sm-offset-2">
					<?php 
						echo $form->hiddenField($articleModel, 'user_id', array('value'=>Yii::app()->session['user_id']));
					?>
					<button class="btn btn-default">提交</button>
				</div>
			</div>
		<?php 
			$this->endWidget();
		?>
	</div>
</div>